home *** CD-ROM | disk | FTP | other *** search
- (*
- ** GEcho 1.00 Developers Kit Demonstration Source Code
- **
- ** Written by Gerard J. van der Land
- **
- ** Copyright (C) 1992 Gerard J. van der Land. All rights reserved.
- **
- ** Last updates: 12-Oct-92
- *)
-
- {$I gestruct.inc}
- {$L pascal.obj}
-
- var
- sys : SETUP_GE;
- AreaHdr : AREAFILE_HDR;
- AreaFile : AREAFILE_GE;
- AreaIdx : array[1..MAXAREAS] of AREAFILE_GEX;
- SetupGE : file;
- AreaFileGE : file;
- AreaFileGEX : file;
- result : word;
- records : word;
- areas : word;
- arearecsize : word;
- counter : word;
- buffer : string[255];
-
- procedure c2p(dest : string ; src : pointer; max : byte); external;
- procedure p2c(dest : pointer; src : string ; max : byte); external;
-
- begin
-
- (*
- ** Opening and reading SETUP.GE
- *)
-
- {$I-}
- assign(SetupGE, 'SETUP.GE');
- reset(SetupGE, 1);
- {$I+}
- if IOresult <> 0 then
- begin
- writeln('Unable to open SETUP.GE');
- halt(255)
- end;
- blockread(SetupGE, sys, sizeof(SETUP_GE), result);
- close(SetupGE);
- if result < sizeof(SETUP_GE) then
- begin
- writeln('Error reading SETUP.GE');
- halt(255)
- end;
- if (sys.sysrev <> GE_THISREV) then
- begin
- writeln('System file revision level mismatch\n');
- halt(251)
- end;
-
- c2p(buffer, @sys.username[1], 35); (* C -> Pascal *)
- writeln('SysOp: ', buffer);
- p2c(@sys.username[1], 'gerard van.der.land', 35); (* Pascal -> C *)
-
- (*
- ** Opening AREAFILE.GE and checking the header
- *)
-
- {$I-}
- assign(AreaFileGE, 'AREAFILE.GE');
- reset(AreaFileGE, 1);
- {$I+}
- if IOresult <> 0 then
- begin
- writeln('Unable to open AREAFILE.GE');
- halt(255)
- end;
- blockread(AreaFileGE, AreaHdr, sizeof(AREAFILE_HDR), result);
- if result < sizeof(AREAFILE_HDR) then
- begin
- writeln('Error reading AREAFILE header');
- halt(255)
- end;
-
- if AreaHdr.recsize < sizeof(AREAFILE_GE) then
- begin
- writeln('Incompatible AREAFILE record size');
- halt(255)
- end;
-
- (*
- ** Reading AREAFILE.GE
- **
- ** Method 1: Using AREAFILE.GEX index file
- ** This will read the area records in alphabetical order, removed area
- ** records are automatically skipped.
- *)
-
- {$I-}
- assign(AreaFileGEX, 'AREAFILE.GEX');
- reset(AreaFileGEX, 1);
- {$I+}
- if IOresult <> 0 then
- begin
- writeln('Unable to open AREAFILE.GEX');
- halt(255)
- end;
- blockread(AreaFileGEX, AreaIdx, sizeof(AreaIdx), result);
- areas := result div sizeof(AREAFILE_GEX);
-
- for counter := 1 to areas do
- begin
- seek(AreaFileGE, AreaIdx[counter].offset);
- blockread(AreaFileGE, AreaFile, sizeof(AREAFILE_GE), result);
- if result = sizeof(AREAFILE_GE) then
- begin
- c2p(buffer, @AreaFile.name, 50);
- writeln(counter, ' ' , buffer)
- end
- end;
-
- (*
- ** Reading AREAFILE.GE
- **
- ** Method 2: Sequentially reading
- ** This will read the area records in the order in which they area stored.
- ** You will have to check each record to see if it has been removed.
- *)
-
- arearecsize := AreaHdr.systems * sizeof(EXPORTENTRY) + AreaHdr.recsize;
- records := (filesize(AreaFileGE) - AreaHdr.hdrsize) div arearecsize;
- areas := 0;
- for counter := 0 to records-1 do
- begin
- seek(AreaFileGE, AreaHdr.hdrsize + longint(arearecsize) * longint(counter));
- blockread(AreaFileGE, AreaFile, sizeof(AREAFILE_GE), result);
- if result = sizeof(AREAFILE_GE) then
- begin
- if (AreaFile.options and REMOVED) = 0 then
- begin
- inc(areas);
- c2p(buffer, @AreaFile.name, 50);
- writeln(areas, ' ' , buffer)
- end
- end
- end;
- close(AreaFileGE);
-
- end.
-
- (* end of file "ge_demo.pas" *)
-